//
//  ComplainViewController.m
//  BaseFrame
//
//  Created by 孟学浩 on 2017/5/11.
//  Copyright © 2017年 com.mxh. All rights reserved.
//

#import "ComplainViewController.h"

@interface ComplainViewController ()

@property (nonatomic,strong) UILabel *phoneLabel;
@property (nonatomic,strong) UITextView *complainTextView;

@end

@implementation ComplainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"投诉";
    
    UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
    lineView1.backgroundColor = getColor(@"f8f8f8");
    
    UIView *telphoneView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, 60)];
    telphoneView.backgroundColor = [UIColor whiteColor];
    telphoneView.userInteractionEnabled = YES;
    [telphoneView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(callPhoneEvent)]];
    [telphoneView addSubview:self.phoneLabel];
    
    UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 70, SCREEN_WIDTH, 10)];
    lineView2.backgroundColor = getColor(@"f8f8f8");
    
    UIView *infoView = [[UIView alloc] initWithFrame:CGRectMake(0, 80, SCREEN_WIDTH, SCREEN_HEIGHT - 80 - 64)];
    infoView.backgroundColor = [UIColor whiteColor];
    [infoView addSubview:self.complainTextView];
    
    [self.view addSubview:lineView1];
    [self.view addSubview:lineView2];
    [self.view addSubview:infoView];
    [self.view addSubview:telphoneView];
}

#pragma mark - Event

- (void)callPhoneEvent{
    [self callPhone:@"15641944668"];
}

#pragma mark - set & get

- (UILabel *)phoneLabel{
    if (!_phoneLabel) {
        _phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 60)];
        _phoneLabel.textColor = getColor(mainColor);
        _phoneLabel.textAlignment = NSTextAlignmentCenter;
        _phoneLabel.font = DEF_FontSize_20;
        NSMutableAttributedString  *attStr = [NSMutableAttributedString new];
        NSTextAttachment *textAtt = [NSTextAttachment new];
        textAtt.image = [UIImage imageNamed:@"phone1"];
        textAtt.bounds = CGRectMake(0, -6, 28, 30);
        
        [attStr appendAttributedString:[NSAttributedString attributedStringWithAttachment:textAtt]];
        [attStr appendAttributedString:[[NSAttributedString alloc] initWithString:@"   投诉电话:15641944668"]];
        _phoneLabel.attributedText = attStr;
    }
    return _phoneLabel;
}

- (UITextView *)complainTextView{
    if (!_complainTextView) {
        _complainTextView = [[UITextView alloc] initWithFrame:CGRectMake(16, 5, SCREEN_WIDTH-32, SCREEN_HEIGHT - 90 - 64)];
        _complainTextView.font = DEF_FontSize_13;
        NSString *temp = @"投诉规则声明:\n投诉是指：权益被侵害者本人对涉案组织侵犯其合法权益的违法犯罪事实，有权向有关国家机关主张自身权利。投诉人，即为权益被侵害者本人。[1]消费者投诉，是指消费者为生活消费需要购买、使用商品或者接受服务，与经营者之间发生消费者权益争议后，请求消费者权益保护组织调解，要求保护其合法权益的行为。";
        
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:temp];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        
        [paragraphStyle setLineSpacing:8];//调整行间距
        
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [temp length])];
        _complainTextView.attributedText = attributedString;
    }
    return _complainTextView;
}

@end
